import request, { QuickResponseData } from '@/utils/request'
import { device as api } from './index'
import { Device } from '@/types/device'
//启用
export const enableDevice = (id: string) => {
  return request({
    url: `${api}/enabled/${id}`,
    method: 'PATCH'
  })
}
//禁用
export const disableDevice = (id: string) => {
  return request({
    url: `${api}/disable/${id}`,
    method: 'PATCH'
  })
}
//删除
export const deleteDevice = (id: string) => {
  return request({
    url: `${api}/${id}`,
    method: 'DELETE'
  })
}
//获取设备分页列表
export const getDevicePageList = (params: object): Promise<QuickResponseData<Array<Device>>> => {
  return request<QuickResponseData<Array<Device>>>({
    url: api,
    method: 'GET',
    params
  })
}
//新增
export const addDevice = (data: Device) => {
  return request({
    url: api,
    method: 'POST',
    data
  })
}
//修改
export const updateDevice = (data: Device) => {
  const { id } = data
  return request({
    url: `${api}/${id}`,
    method: 'PUT',
    data
  })
}
